<?php

/*
*
* BEGIN side_nav_content.php
*
*
* Dazzler Side Nav HTML Content
* @Description: The class creates all the UIs for the side nav of different pages of dazzler
* @Authors: Salman, Wits University
* @Copyright: © Wits University 2011 - All Rights Reserved
* @License: BSD License (http://www.linfo.org/bsdlicense.html)
*
*
* BEGIN CHANGELOG
* Developers working on thee files are REQUIRED to maintain this CHANGELOG.
* Please ensure you follow the Changelog Guidelines: http://code.google.com/p/dazzler/wiki/DazzlerDevelopGuideline?ts=1315476570&updated=DazzlerDevelopGuideline
* !==================================================================================================================================================================
*
* VERSION 1.0.0
*	+ File Created, Salman, 20 September 2011
*
* ==================================================================================================================================================================!
* END CHANGELOG
*/


/*******************************************************************************************************************************************************************
*
* BEGIN Direct Call Check
*
/******************************************************************************************************************************************************************/
global $doNotCallThisScriptDirectly;
if ($doNotCallThisScriptDirectly != 1)
{
	/* Read the ini language file */
	$ini_lang_array = array();
	$clientlang = explode(",", strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
	$lang_ini_array = (file_exists("lang/" . trim($clientlang[0]) . ".ini")) ? parse_ini_file("lang/" . trim($clientlang[0]) . ".ini", true) : parse_ini_file("lang/en.ini", true);
	die ($lang_ini_array['ERRORS']['doNotCallThisScriptDirectly']);
}
/*******************************************************************************************************************************************************************
*
* END Direct Call Check
*
/******************************************************************************************************************************************************************/

class side_nav_content extends baseClass
{

    private $htmlelementsbuilder;

    private $parsesiteconfig;

    public function  __construct()
    {
    $this->htmlelementsbuilder = new htmlelementsbuilder();
    $this->parsesiteconfig = new parsesiteconfig();
    parent::parseLanguageErrorLogFile();
    }

     /**
     * \brief Builds html content for one side link item
     * return Return one side link item
     */
    private function buildSideNavLnkItem($txt,$classItem,$href)
    {
     	if (isset($txt) && isset($classItem) && isset($href))
        {
            return "<div class='lnitem'><a href=$href class=$classItem> $txt</a></div>";
        }
        else
        {
            die($this->lang_ini_array['ERROR']['ArgumentsNotSetSideNav']);
        }
    }

     /**
     * \brief This function builds html content for the side nav for the main page
     * \return This returns  html content for the side nav for the main page
     */
    private function buildMainSideNav()
    {
        $sideNav = $this->buildSideNavLnkItem('&raquo; Log In', "dazzler_login_link", "#login");
        $sideNav .= $this->buildSideNavLnkItem('&raquo; Register', "dazzler_registration_link", "#register");
        return $sideNav;

    }
    
     /**
     * \brief This function builds html content for the side nav for the commentator page
     * \return This returns  html content for the side nav for the commentator page
     */
    private function buildCommentatorSideNav()
    {

$userAdmin = new UserAdmin();
$UserLogic = new UserLogic();
$isCommentator =  $UserLogic->isUserCommentator();
//echo $isLoggedOn = $UserLogic->isUsernameSet();
//print_r($UserLogic->getCommentatorId());
      if ($isCommentator == TRUE)
      {

            $CommentatorID = $UserLogic->getCommentatorId();
          $userDetails = $userAdmin->getCommentatorDetailsWithId("$CommentatorID");

//          ->getCommentatorDetails($userName)
//          ->getCommentatorDetails($userName);
      }
//      else
//      {
//         die("You have logged on illegally.");
//      }

      $userDetails['USER_FNAME'].$userDetails['USER_LNAME'];
      $sideNav = "<div>". $userDetails['USER_FNAME']." ". $userDetails['USER_LNAME']." signed in</div>";
      $sideNav .= '<div style="display:block; clear:both;">&nbsp;</div>';

        $sideNav .= $this->buildSideNavLnkItem('&raquo; My Profile', "my_profile_link", "#myprofile");
        $sideNav .= $this->buildSideNavLnkItem('&raquo; Games', "games_link", "games");
        $sideNav .= $this->buildSideNavLnkItem('&raquo; Players', "players_link", "players");
        $sideNav .= $this->buildSideNavLnkItem('&raquo; Teams', "teams_link", "teams");


        $sideNav .= $this->buildSideNavLnkItem('&raquo; Sign Out', "sign_out_link", "signout");
        return $sideNav;

    }


         /**
     * \brief This function builds html content for the side nav for the cricket fan page
     * \return This returns  html content for the side nav for the cricket fan page
     */
    private function buildCricketFanSideNav()
    {

$userAdmin = new UserAdmin();
$UserLogic = new UserLogic();
//echo $isCommentator =  $UserLogic->isUserCommentator();
//echo $UserLogic->isUsernameSet();
if($UserLogic->isLoggedOn())
{
$userName = $UserLogic->getUsername();
$userDetails = $userAdmin->getFanDetails("$userName");
}
 else {
 die("You have logged on illegally.");
}
//print_r($userName);
//echo $isLoggedOn = $UserLogic->isUsernameSet();
//print_r($UserLogic->getCommentatorId());
//      if ($isCommentator == TRUE)
//      {
//
//            $CommentatorID = $UserLogic->getCommentatorId();
//          $userDetails = $userAdmin->getCommentatorDetailsWithId("$CommentatorID");
//
////          ->getCommentatorDetails($userName)
////          ->getCommentatorDetails($userName);
//      }
//      else
//      {
//         die("You have logged on illegally.");
//      }

      $userDetails['USER_FNAME'].$userDetails['USER_LNAME'];
      $sideNav = "<div>". $userDetails['USER_FNAME']." ". $userDetails['USER_LNAME']." signed in</div>";
      $sideNav .= '<div style="display:block; clear:both;">&nbsp;</div>';

        $sideNav .= $this->buildSideNavLnkItem('&raquo; My Profile', "my_profile_link", "#myprofile");
        $sideNav .= $this->buildSideNavLnkItem('&raquo; Games', "games_link", "games");
        $sideNav .= $this->buildSideNavLnkItem('&raquo; Players', "players_link", "players");
        $sideNav .= $this->buildSideNavLnkItem('&raquo; Teams', "teams_link", "teams");


        $sideNav .= $this->buildSideNavLnkItem('&raquo; Sign Out', "sign_out_link", "signout");
        return $sideNav;

    }







     /**
     * \brief This function builds html content for the side nav for the main page
     * \return This returns  html content for the side nav for the main page
     */
    public function showMainSideNav()
    {
        return $this->buildMainSideNav();
    }

     /**
     * \brief This function builds html content for the side nav for the main page
     * \return This returns  html content for the side nav for the main page
     */
    public function showCommentatorSideNav()
    {
        return $this->buildCommentatorSideNav();
    }


         /**
     * \brief This function builds html content for the side nav for the cricket fan side
     * \return This returns  html content for the side nav for the cricket fan page
     */
    public function showCricketFanSideNav()
    {
        return $this->buildCricketFanSideNav();
    }

}